package com.esaheki.flashcards.uiSupport;

import java.sql.SQLException;
import java.util.ArrayList;

import com.esaheki.flashcards.classes.*;
import com.esaheki.flashcards.dao.*;

public class UserTree {

	public ArrayList<User> getUserTree() {
		ArrayList<User> userlist = new ArrayList<User>();
        try {
			UserDAO uDao = new UserDAO();
			CategoryDAO cDao = new CategoryDAO();
			userlist = uDao.getUserList();
			for (User user : userlist) {
				user.setCategories(cDao.getCategoryList(user));
			}
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		return userlist;
	}
}
